package com.hps.demo.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;

/**
 * @author heps
 * @since 2020/6/10 9:52
 */
@Slf4j
public class HelloSimpleJob implements SimpleJob {

  @Override
  public void execute(ShardingContext shardingContext) {
    log.info(String.format("Hello! Thread ID: %s, 作业分片总数: %s, " +
            "当前分片项: %s.当前参数: %s," +
            "作业名称: %s.作业自定义参数: %s"
        ,
        Thread.currentThread().getId(),
        shardingContext.getShardingTotalCount(),
        shardingContext.getShardingItem(),
        shardingContext.getShardingParameter(),
        shardingContext.getJobName(),
        shardingContext.getJobParameter()
    ));

    Gson gson = new Gson();
  }
}
